<?php

/*

  Treasure	$5

  Worth $2
  While this is in play, when you gain a card, you may put that card on top of your deck.

 */

class RoyalSeal extends Card implements iTreasure, iKingdom, iProsperity, iReactingCard {

    private $reactConditions;

    public function __construct() {
        parent::__construct("Royal Seal", 5);
        $this->value = new Price(2);
        $this->undoPlay = true;
        $this->undoBuy = true;

        $this->reactConditions = new ReactionConditions();
        $this->reactConditions->action = array(Gain);
        $this->reactConditions->actor = array(Yourself);
        $this->reactConditions->cardLocation = array(PlayArea);
        $this->reactConditions->limit = ForEachCard;
    }

    public function getDescription() {
        return array(
            " Worth $2",
            "While this is in play, when you gain a card, you may put that card on top of your deck.");
    }
    
    public function autoPlayNum(Game $game) {
        return -1;
    }

    public function getConditions() {
        return $this->reactConditions;
    }

    public function isReactRelevant(Game $game, $card, $name) {
        return true;
    }

    public function react(Game $game, $card, $name) {
        ScreenDisplay::addScreenMessage($game, true, "activate " . nicePrint($this), "activates " . nicePrint($this), $name);

        $options = array(new Option(1, "Yes"), new Option(2, "No"));
        $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Put " . $card->getValue() . " on top of the deck?", $name);
        $answer = $output[0];
        if ($answer == "Yes") {
            ScreenDisplay::addScreenMessage($game, true, "put " . nicePrint($card) . " on top of your deck", "puts " . ScreenDisplay::$LMSG . " cards of top of his deck", $name);
            $game->setDestinationPile(DrawPile);
        } else {
            $game->setDestinationPile(DiscardPile);
        }
        $game->setTempCard($card);
        return true;
    }

}

?>